package com.theatre.userservice.service.task;

import com.theatre.userservice.service.ScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ScriptExpireTask {

    @Autowired
    private ScriptService scriptService;

    // 每天凌晨1点执行一次
    @Scheduled(cron = "0 0 1 * * ?")
    public void expireScripts() {
        int updatedCount = scriptService.expireScripts();
        System.out.println("定时任务执行完成，标记 " + updatedCount + " 个剧本为已到期");
    }
}
